package com.yeeft.ocr.web;

import com.yeeft.ocr.domain.model.request.OcrRequest;
import com.yeeft.ocr.domain.model.response.OcrResponse;
import com.yeeft.ocr.domain.model.response.Response;
import com.yeeft.ocr.domain.vo.CompanyLicense;
import com.yeeft.ocr.service.CompanyLicenseAliService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 功能简要描述
 *
 * @author 赵仲文
 * @Copyright (c) 2016, frontpay.cn
 * @date 2018/5/9 9:14
 */
@Controller
public class OcrController {
    @Autowired
    private CompanyLicenseAliService companyLicenseAliService;

    /**
     *  管理后台首页
     */
    @RequestMapping("/")
    public String index() {
        return "home";
    }
    @RequestMapping("/ocr-query")
    public String ocrQuery() {
        return "ocr-query";
    }
    @RequestMapping("/ocr-reg")
    public String ocrReg() {
        return "ocr-reg";
    }

    /**
     *  营业执照识别
     */

    @RequestMapping(value = "/api/companyLicense", method = RequestMethod.POST)
    public @ResponseBody
    Response<OcrResponse<CompanyLicense>> getCompanyLicense(@RequestBody OcrRequest request) {

        OcrResponse<CompanyLicense> data = companyLicenseAliService.getCompanyLicense(request);

        Response<OcrResponse<CompanyLicense>> companyLicenseResponse = new Response<OcrResponse<CompanyLicense>>();
        companyLicenseResponse.setCode("100");
        companyLicenseResponse.setData(data);

        return companyLicenseResponse;
    }
}
